package cn.tedu.shoppingmall.controller;

import cn.tedu.shoppingmall.mapper.CommentMapper;
import cn.tedu.shoppingmall.mapper.CommentUserMapper;
import cn.tedu.shoppingmall.vo.Comment;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
@Api(tags = "5评论模块")
@RestController
@RequestMapping("/CU")
public class CommentUserController {

    @Autowired
    CommentMapper commentMapper;
    @Autowired
    CommentUserMapper commentUserMapper;


    //点赞加一
    @RequestMapping("/addGood/{id}")
    public Comment addGood(@PathVariable int id){
        if (commentMapper.addGood(id)==1){
            return commentMapper.findOneById(id);
        }
            return null;
    }
    //踩一踩加一
    @RequestMapping("/addNo/{id}")
    public Comment addNo(@PathVariable int id){
        if (commentMapper.addNo(id)==1){
            return commentMapper.findOneById(id);
        }
        return null;
    }
    //点赞减一
    @RequestMapping("/delGood/{id}")
    public Comment delGood(@PathVariable int id){
        if (commentMapper.delGood(id)==1){
            return commentMapper.findOneById(id);
        }
        return null;
    }
    //踩一踩减一
    @RequestMapping("/delNo/{id}")
    public Comment delNo(@PathVariable int id){
        if (commentMapper.delNo(id)==1){
            return commentMapper.findOneById(id);
        }
        return null;

    }
}
